import { WXLOGIN_INFO } from '../mumation-type'
import  * as  api from '@/api/index'
import  thirdApi  from '@/api/third'
import cache from '@/common/cache'
export default {
    namespaced: true,
    state: {
        wx_login_info:{},
    },
    mutations:{
        [WXLOGIN_INFO](state, data){
            state.wx_login_info = data
        },
    },
    actions:{
        setInfo({commit,state},data){
            commit(WXLOGIN_INFO,data)
        },
        login({commit,state}){
            return new Promise(resolve => {
                thirdApi.login().then(res=>{
                    if(res){
                        console.log('登录获取code:'+res)
                        api.wxxcxLogin({code:res}).then(res1=>{

                            console.log('获取session_key')
                            console.log(res1)
                            commit(WXLOGIN_INFO,res1.data)
                            resolve(res1.data)
                        })
                    }
                })
            })

        }
    }
}
